//
//  PaymentViewController.m
//  giuseppe
//
//  Created by 王晨辉 on 15/8/13.
//  Copyright (c) 2015年 GiantUmbrella. All rights reserved.
//

#import "PaymentViewController.h"


@interface PaymentViewController ()<UITableViewDataSource,UITableViewDelegate>{

    UITableView *payTableView;
    
}

@end

@implementation PaymentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIView *navView1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    navView1.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:navView1];

    //自定义的导航栏
    UIView *navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 64)];
    navView.backgroundColor = [UIColor whiteColor];
    navView.alpha = 0.90;
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CGRectMake(10, 33, 27, 16);
    [backButton setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth/2-50, 20, 100, 40)];
    titleLabel.text = @"订单支付";
    titleLabel.textAlignment = NSTextAlignmentCenter;
    
    UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 64, kScreenWidth, 1)];
    view.backgroundColor = UIColorWithRGBA(229, 229, 231, 1);
    
    [self.view addSubview:view];
    [navView addSubview:backButton];
    [navView addSubview:titleLabel];
    [self.view addSubview:navView];
    
    [self subView];
    
}
-(void)subView{
    
    payTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, kScreenWidth, 150+80+80)];
    payTableView.delegate = self;
    payTableView.dataSource = self;
    payTableView.scrollEnabled = NO;

    
    UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 150)];
    headerView.backgroundColor = baseColor;
    
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 10, 40, 10)];
    titleLabel.text = @"需支付";
    titleLabel.textColor = [UIColor grayColor];
    titleLabel.font = [UIFont systemFontOfSize:12];
    
    [headerView addSubview:titleLabel];
    
    
    
    UILabel *priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 30, kScreenWidth-60, 90)];
    priceLabel.backgroundColor = [UIColor whiteColor];
    priceLabel.layer.masksToBounds = YES;
    priceLabel.layer.cornerRadius = 3;
    priceLabel.layer.borderWidth = 1;
    priceLabel.layer.borderColor = [UIColor lightGrayColor].CGColor;
    priceLabel.text = [NSString stringWithFormat:@"￥ %@",self.priceString];
    priceLabel.textColor = mainColor;
    priceLabel.font = [UIFont systemFontOfSize:30];
    priceLabel.textAlignment = NSTextAlignmentCenter;
    
    [headerView addSubview:priceLabel];
    
    payTableView.tableHeaderView = headerView;
    
    [self.view addSubview:payTableView];
       
}


#pragma mark--- tableViewDelegate 每个区的行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 2;
    
}

#pragma mark--- tableViewDelegate 区尾的高度

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    

    return 80;
    
}


#pragma mark--- tableViewDelegate cell

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    static NSString *indentify = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentify];
    
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentify];
    
    
    UIImageView *logoImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 60, 60)];
    
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 10, kScreenWidth-80, 30)];
    
    
    UILabel *contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 30, kScreenWidth-80, 40)];
    contentLabel.font = [UIFont systemFontOfSize:14];
    contentLabel.textColor = [UIColor lightGrayColor];
    
    
    if (indexPath.row == 0) {
        
        logoImageView.image = [UIImage imageNamed:@"icon_zfb"];
        titleLabel.text = @"支付宝客户端支付";
        contentLabel.text = @"推荐已安装支付宝客户端的用户使用";
        
    }else{
        
        logoImageView.image = [UIImage imageNamed:@"icon_weixin"];
        titleLabel.text = @"微信支付";
        contentLabel.text = @"推荐已安装微信客户端的用户使用";
        
        
    }
    
    [cell.contentView addSubview:logoImageView];
    [cell.contentView addSubview:titleLabel];
    [cell.contentView addSubview:contentLabel];
    
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
    
    
}

#pragma mark--- tableViewDelegate 点击方法

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}




- (void)back{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
